/*
 * @Author: 0x9DEFA478
 * @Date: 2022-01-26 22:14:24
 * @LastEditTime: 2022-03-29 18:51:44
 * @LastEditors: 0x9DEFA478
 * @Description: 
 * QQ:2652450237
 * ============================================================================================================================================
 * 
 * 
 * 
 *                                                                                               ************      ****************************
 *                                                                                             ************      ****************************  
 *                                                                                           ************      ****************************    
 *                                                                                         ************      ****************************      
 *                                                                                       ************      ************                        
 *                                                                                     ************      ************                          
 *                                                                                   ************      ************                            
 *                                                                                 ************      ************                              
 *                                                                               ************      ************                                
 *                                                                             ************      ************                                  
 *                                                                           ************      ************                                    
 *                                                                         ************      ************                                      
 *                                                                       ************      ************                                        
 *                                                                     ************      ************                                          
 *                                                                   ************      ************                                            
 *                                                                 ************      ************                                              
 *                                                               ************      ************                                                
 *                                                             ************      ************                                                  
 *                                                           ************      ************                                                    
 *                                                         ************      ************                                                      
 *                                                       ************      ************                                                        
 *                                                     ************      ************                                                          
 *                                                   ************      ************                                                            
 *                                                 ************      ************                                                              
 *                                               ************      ************                                                                
 *                                             ************      ************                                                                  
 *                                           ************      ************                                                                    
 *                                         ************      ************                                                                      
 *                                       ************      ************                                                                        
 *                                     ************      ************                                                                          
 *                                   ************      ************                                                                            
 *                                 ************      ************                                                                              
 *                               ************      ************                                                                                
 *                             ************      ************                                                                                  
 *                           ************      ************                                                                                    
 *                         ************      ************                                                                                      
 *       ****************************      ************                                                                                        
 *     ****************************      ************                                                                                          
 *   ****************************      ************                                                                                            
 * ****************************      ************                                                                                              
 * 
 * 
 * 
 * ============================================================================================================================================
 * 
 */
#include "../H_NES_Mapper.h"




extern void H_NES_Mapper0_PRG_Write_NROM128(Hbyte Value,Huint16 Address,void* v);
extern Hbyte H_NES_Mapper0_PRG_Read_NROM128(Huint16 Address,void* v);
extern Huint16 H_NES_Mapper0_PRG_Read16_NROM128(Huint16 Address,void* v);
extern void H_NES_Mapper0_PRG_Write_NROM256(Hbyte Value,Huint16 Address,void* v);
extern Hbyte H_NES_Mapper0_PRG_Read_NROM256(Huint16 Address,void* v);
extern Huint16 H_NES_Mapper0_PRG_Read16_NROM256(Huint16 Address,void* v);
extern void H_NES_Mapper0_CHR_Exception_Write(Hbyte Value,Huint16 Address,void* v);
extern void H_NES_Mapper0_CHR_Write(Hbyte Value,Huint16 Address,void* v);
extern Hbyte H_NES_Mapper0_CHR_Read(Huint16 Address,void* v);




int H_NES_Mapper0_Init(void* v){
  H_NES_Console* Console;

  Console=v;

  if(Console->Cartridge.Mapper.PRG_RAM_Size!=0){
    return vH_NES_Result_ROMError;
  }



  Console->Cartridge.Mapper.DeInit=NULL;

  if(Console->Cartridge.Mapper.PRG_ROM_Size<(32U*1024U)){
    Console->Cartridge.PRG_Write=H_NES_Mapper0_PRG_Write_NROM128;
    Console->Cartridge.PRG_Read=H_NES_Mapper0_PRG_Read_NROM128;
    Console->Cartridge.PRG_Read16=H_NES_Mapper0_PRG_Read16_NROM128;
  }else{
    Console->Cartridge.PRG_Write=H_NES_Mapper0_PRG_Write_NROM256;
    Console->Cartridge.PRG_Read=H_NES_Mapper0_PRG_Read_NROM256;
    Console->Cartridge.PRG_Read16=H_NES_Mapper0_PRG_Read16_NROM256;
  }

  if(Console->Cartridge.Mapper.CHR_ROM_Size==0U){
    Console->Cartridge.CHR_Write=H_NES_Mapper0_CHR_Write;
  }else{
    Console->Cartridge.CHR_Write=H_NES_Mapper0_CHR_Exception_Write;
  }
  Console->Cartridge.CHR_Read=H_NES_Mapper0_CHR_Read;

  Console->Cartridge.Progress.Size=H_NES_Mapper_DefaultProgressSize(Console);
  Console->Cartridge.Progress.Get=H_NES_Mapper_DefaultGetProgress;
  Console->Cartridge.Progress.Load=H_NES_Mapper_DefaultLoadProgress;

  
  

  return vH_NES_Result_OK;
}



